package com.five.community.service.impl;

import com.five.community.bean.Building;
import com.five.community.bean.vo.BuildingVo;
import com.five.community.mapper.BuildingMapper;
import com.five.community.service.BuildingService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BuildingServiceImpl implements BuildingService {
    @Autowired
    private BuildingMapper buildingMapper;

    @Override
    public List<BuildingVo> selectAllByName(Integer pageNum, Integer pageSize, String name) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return buildingMapper.selectByName(name);
    }

    @Override
    public List<BuildingVo> selectAll() throws Exception {
        return buildingMapper.selectAll();
    }

    @Override
    public List<BuildingVo> selectAllBuildings(Integer pageNum, Integer pageSize) throws Exception {
        PageHelper.startPage(pageNum,pageSize);
        return buildingMapper.selectAll();
    }

    @Override
    public void insert(Building building) throws Exception {
        buildingMapper.insert(building);
    }

    @Override
    public void deleteById(long id) throws Exception {
        buildingMapper.delete(id);
    }

    @Override
    public List<BuildingVo> selectByName(String name) throws Exception {
        return buildingMapper.selectByName(name);
    }

    @Override
    public Building selectById(long id) throws Exception {
        return buildingMapper.selectById(id);
    }

    @Override
    public void update(Building building) throws Exception {
        buildingMapper.update(building);
    }
}
